#ifndef MASOCKET_H
#define MASOCKET_H

#include <QtGui>
#include <QtNetwork>

#include "Proto.h"

class MaSocket : public QObject
{
    Q_OBJECT

public:
    MaSocket(QTcpSocket *socket, QObject *parent);
    ~MaSocket();

    QTcpSocket *getSocket();
    void envoyerMessage(quint8 idApplication, quint8 idMessage, const QString &message = "");
    void envoyerMessage(quint8 idApplication, quint8 idMessage, const QByteArray &message);
    void deconnecterSocket();

protected:
    QTcpSocket* socket;
    QObject* parent;
    quint16 tailleMessage;

    virtual void traitementMessage(quint8 typeApplication, quint8 typeMessage, QByteArray contenu) = 0;

        private slots:
    void donneesRecues();

};

#endif // MASOCKET_H
